package com.example.asus.practice;

import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.AppCompatSeekBar;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.Toast;

public class Seekbar extends AppCompatActivity {
    SeekBar seekBar;
    ImageView iv1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_seekbar);
        seekBar = (AppCompatSeekBar)findViewById(R.id.appCompatSeekBar);
        iv1 = (ImageView)findViewById(R.id.iv1);
        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                Toast.makeText(Seekbar.this, "进度改变："+ progress, Toast.LENGTH_SHORT).show();
                iv1.setImageAlpha(progress);
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                Toast.makeText(Seekbar.this, "开始触摸", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                Toast.makeText(Seekbar.this, "停止触摸", Toast.LENGTH_SHORT).show();
            }
        });



    }
}
